// https://apifox-openapi.apifox.cn/api-173409873
const PROJECT_ID = '6949329'
const TOKEN = 'APS-vO5c9EYAXgq5oISoOp8qRbgy8ve6WuSE'
// URL必须是外网可以访问的
const API_URL = 'http://douxian.zhuzhu.pro:2285/api-docs/json'
const IMPORT_URL = `https://api.apifox.com/v1/projects/${PROJECT_ID}/import-openapi`;

// async function bodyJson() {
//   const response = await fetch(API_URL)
//   const data = await response.json()
//   return data
// }

(async () => {
  // const jsonData = await bodyJson()
  const response = await fetch(IMPORT_URL, {
    method: 'POST',
    headers: {
      'X-Apifox-Api-Version': '2024-03-28',
      'Authorization': `Bearer ${TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      input: {
        url: API_URL,
      },
      // input: jsonData,
    }),
  })
  // const text = await response.text()
  // console.log('Raw Response:', text)
  const json = await response.json()
  console.log(JSON.stringify(json, null, 2))
})()
